//
//  ManagerTableViewCell.m
//  NewBook
//
//  Created by dlios on 15-3-7.
//  Copyright (c) 2015年 dlios. All rights reserved.
//

#import "ManagerTableViewCell.h"

@implementation ManagerTableViewCell
-(void)dealloc
{
    
    [_bookShelfImageView release];
    [_whiteView release];
    [_bookCoverImageView release];
    [_bookNameLable release];
    [_bookReferLable release];
    [_salePriceImaegView release];
    [_originalPriceImageView release];
    [_salePriceLable release];
    [_originalPriceLable release];
    [super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}


- (void)createSubViews
{
    //书架图片
    self.bookShelfImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 375, 100)];
    self.bookShelfImageView.image = [UIImage imageNamed:@"2.png"];
    [self.contentView addSubview:self.bookShelfImageView];
    [_bookShelfImageView release];
    //白色底框
    self.whiteView = [[UIView alloc] initWithFrame:CGRectMake(12, 0, 353, 85)];
    self.whiteView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.whiteView];
    [_whiteView release];
    
    //书的图片
    self.bookCoverImageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 0, 90, 85)];
    self.bookCoverImageView.backgroundColor = [UIColor whiteColor];
    [self.whiteView addSubview:self.bookCoverImageView];
    [_bookCoverImageView release];
    
    
    //书名
    self.bookNameLable = [[UILabel alloc] initWithFrame:CGRectMake(self.bookCoverImageView.frame.origin.x + self.bookCoverImageView.frame.size.width + 10, self.bookCoverImageView.frame.origin.y, 250, 30)];
    [self.contentView addSubview:self.bookNameLable];
    [_bookNameLable release];
    
    //书的简介
    self.bookReferLable = [[UILabel alloc] initWithFrame:CGRectMake(self.bookCoverImageView.frame.origin.x + self.bookCoverImageView.frame.size.width + 10, self.bookCoverImageView.frame.origin.y + 30, 250, 25)];
    self.bookReferLable.textColor = [UIColor grayColor];
    self.bookReferLable.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:self.bookReferLable];
    [_bookReferLable release];
    
    //优惠价图片
    self.salePriceImaegView = [[UIImageView alloc] initWithFrame:CGRectMake(self.bookCoverImageView.frame.origin.x + self.bookCoverImageView.frame.size.width + 10, self.bookCoverImageView.frame.origin.y + 55, 25, 25)];
    self.salePriceImaegView.image = [UIImage imageNamed:@"iconfont-youhuiquan.png"];
    [self.contentView addSubview:self.salePriceImaegView];
    [_salePriceImaegView release];
    //原价图片
    self.originalPriceImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.bookCoverImageView.frame.origin.x + self.bookCoverImageView.frame.size.width + 120, self.bookCoverImageView.frame.origin.y + 57, 20, 20)];
    self.originalPriceImageView.image = [UIImage imageNamed:@"iconfont-renminbi.png"];
    [self.contentView addSubview:self.originalPriceImageView];
    [_originalPriceImageView release];
    //优惠价文字
    self.salePriceLable = [[UILabel alloc] initWithFrame:CGRectMake(self.salePriceImaegView.frame.origin.x + self.salePriceImaegView.frame.size.width + 10, self.salePriceImaegView.frame.origin.y, 70, 25)];
    self.salePriceLable.textColor = [UIColor redColor];
    self.salePriceLable.font = [UIFont systemFontOfSize:22];
    [self.contentView addSubview:self.salePriceLable];
    [_salePriceLable release];
    //原价文字
    self.originalPriceLable = [[UILabel alloc] initWithFrame:CGRectMake(self.originalPriceImageView.frame.origin.x + self.originalPriceImageView.frame.size.width + 10, self.originalPriceImageView.frame.origin.y - 3, 50, 25)];
    self.originalPriceLable.textColor = [UIColor grayColor];
    
    [self.contentView addSubview:self.originalPriceLable];
    [_originalPriceLable release];
    
    
}

- (void)setYoungBook:(YoungBook *)youngBook
{
    if (_youngBook != youngBook) {
        [_youngBook release];
        _youngBook = [youngBook retain];
    }
    
    NSURL *url = [NSURL URLWithString:youngBook.image_url];
    //sd请求图片
    [self.bookCoverImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"picLib_default@2x.png"]];
    //重新赋值
    self.bookNameLable.text = youngBook.name;
    self.bookReferLable.text = youngBook.subname;
    self.salePriceLable.text = youngBook.dd_sale_price;
    self.originalPriceLable.text = youngBook.original_price;
    
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
